# -*- coding: utf-8 -*-
"""zqxt_views URL Configuration

The `urlpatterns` list routes URLs to views. For more information please see:
    https://docs.djangoproject.com/en/1.11/topics/http/urls/
Examples:
Function views
    1. Add an import:  from my_app import views
    2. Add a URL to urlpatterns:  url(r'^$', views.home, name='home')
Class-based views
    1. Add an import:  from other_app.views import Home
    2. Add a URL to urlpatterns:  url(r'^$', Home.as_view(), name='home')
Including another URLconf
    1. Import the include() function: from django.conf.urls import url, include
    2. Add a URL to urlpatterns:  url(r'^blog/', include('blog.urls'))
"""
from django.conf.urls import url
from django.contrib import admin
from calc import views as calc_views

urlpatterns = [
    url(r'^$', calc_views.index, name='home'),
    #这里修改url后，不用修改模板、视图，使用新的链接打开以前的网址
    # (实质在视图中新增old_add2_redirect函数，和修改url)
    #旧链接：http://127.0.0.1:8000/add/4/5/，新链接：http://127.0.0.1:8000/new_add/4/5/
    #注意看重点 add 变成了 new_add，但是后面的 name='add2' 没改，这时 {% url 'add2' 4 5 %}
    #就会渲染对应的网址成 /new_add/4/5/
    url(r'^new_add/(\d+)/(\d+)/$', calc_views.add2, name='add2'),

    #url(r'^add/(\d+)/(\d+)/$', calc_views.add2, name='add2'),
    url(r'^add/(\d+)/(\d+)/$', calc_views.old_add2_redirect),

    url(r'^admin/', admin.site.urls),
]
